﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TravelClassLibrary;
namespace CSE445HW5.UserProtected
{
    public partial class CountdownUserControl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void calendar_SelectionChanged(object sender, EventArgs e)
        {
            textBoxDate.Text = calendar.SelectedDate.ToShortDateString();
            DateTime selectedDate = calendar.SelectedDate;
            string countDays = TravelClass.getTimeUntilDate(selectedDate);
            Int32 days = Int32.Parse(countDays);
            
            string dayStr = "";
            if(days == 1)
                dayStr = "Day";
            else
                dayStr = "Days";
                
            outputCount.Text = countDays  + " " + dayStr +  " Until " + calendar.SelectedDate.ToLongDateString();
        }
      
    }
}